<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.min.js"></script>
</head>
<body>
    <div id='app'>
        <h1>首页</h1>
        
        <router-link :to="{path:'/register',query:{name:'zhangsan'}}">注册账号</router-link>
        <router-view></router-view>
    </div>
    <template id="demo">
        <div>
            我是首页
        </div>
    </template>
    <script>
        let index={
            template:"#demo"
        }
    </script>
    <!--  -->
    <!-- 注册账号 -->
    <template id="register">
        <div>
            注册账号
        </div>
    </template>
    <script>
        let register={
            template:"#register",
            created(){
                console.log(this.$route.query);
                
            }
        }
    </script>
    <script>
        let router=new VueRouter({
            routes:[
                {
                    path:"/",
                    component:index
                },
                {
                    path:"/register",
                    component:register
                }
            ]
        })
    const vm = new Vue({
        el: '#app',
        data: {
        },
        router

    })
    </script>
</body>
</html>